package com.cheyunkeji.er.utils;

import com.cheyunkeji.er.Constants;
import com.cheyunkeji.er.bean.UnAvailableChannelBean;
import com.cheyunkeji.er.bean.UserInfo;

import java.util.List;

/**
 * Created by Michael on 2017/4/22 22:57.
 */

public class ChannelInfoUtil {

    /**
     * 序列化通道列表信息
     * @param channelList
     */
    public static void saveChannelInfoList(List<UserInfo.ChannelListBean> channelList){

        SerializeUtil.save(Constants.CHANNEL_INFO_SERIALIZE_FILE, Constants.CHANNEL_INFO_SERIALIZE_KEY, channelList);
    }

    /**
     * 反序列化可用通道列表信息
     */
    public static List<UserInfo.ChannelListBean> getChannelInfoList(){
        return (List<UserInfo.ChannelListBean>) SerializeUtil.get(Constants.CHANNEL_INFO_SERIALIZE_FILE, Constants.CHANNEL_INFO_SERIALIZE_KEY);
    }

    /**
     * 序列化当前选中通道信息
     * @param channelListBean
     */
    public static void saveCurrentChannelInfo(UserInfo.ChannelListBean channelListBean){
        SerializeUtil.save(Constants.CHANNEL_INFO_SERIALIZE_FILE, Constants.CHANNEL_INFO_CURRENT_CHANNEL,channelListBean);
    }

    /**
     * 反序列化当前所在通道信息
     * @return
     */
    public static UserInfo.ChannelListBean getCurrentChannelInfo(){
        return (UserInfo.ChannelListBean) SerializeUtil.get(Constants.CHANNEL_INFO_SERIALIZE_FILE,Constants.CHANNEL_INFO_CURRENT_CHANNEL);
    }

    /**
     * 序列化当前不可用通道列表
     * @param unAvailableChannelList
     */
    public static void saveUnavailableChannelList(List<UnAvailableChannelBean> unAvailableChannelList){
        SerializeUtil.save(Constants.CHANNEL_INFO_SERIALIZE_FILE,Constants.CHANNEL_LIST_UNAVAILABLE,unAvailableChannelList);
    }

    /**
     * 反序列化当前不可用通道列表
     * @return
     */
    public static List<UnAvailableChannelBean> getUnavailableChannelList(){
        return (List<UnAvailableChannelBean>) SerializeUtil.get(Constants.CHANNEL_INFO_SERIALIZE_FILE,Constants.CHANNEL_LIST_UNAVAILABLE);
    }

}
